<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<lv-tabs [(lvActiveIndex)]="activeIndex">
    <lv-tab [lvTitle]="'common_basic_info_label' | i18n" [lvId]="'0'">
        <ng-template lv-tab-lazy>
            <lv-form class="formGroup">
                <ng-container *ngFor="let backupItem of policy?.policy_list">
                    <h3 class="aui-gutter-column-md">{{backupItem.name}}</h3>
                    <lv-form-item>
                        <lv-form-label>{{'explore_detecte_mode_label' | i18n}}</lv-form-label>
                        <lv-form-control>
                            {{backupItem.ext_parameters?.need_detect | textMap: 'detectionMethod'}}
                        </lv-form-control>
                    </lv-form-item>
                    <lv-form-item>
                        <lv-form-label>{{'explore_depth_detection_label' | i18n}}</lv-form-label>
                        <lv-form-control>
                            {{(backupItem.ext_parameters?.is_backup_detect_enable ?
                            'operation_open_dynamic_detect_label' :
                            'operation_close_dynamic_detect_label') | i18n}}
                        </lv-form-control>
                    </lv-form-item>
                    <lv-form-item *ngIf="backupItem.ext_parameters?.is_backup_detect_enable">
                        <lv-form-label>{{'explore_detection_sensitivity_label' | i18n}}</lv-form-label>
                        <lv-form-control>
                            {{backupItem.ext_parameters?.upper_bound | textMap: 'detectUpperBond'}}
                        </lv-form-control>
                    </lv-form-item>
                    <lv-form-item>
                        <lv-form-label>{{'protection_lock_no_anti_data_label' | i18n}}</lv-form-label>
                        <lv-form-control>
                            {{(backupItem.ext_parameters?.is_security_snap ? 'operation_open_dynamic_detect_label' :
                            'operation_close_dynamic_detect_label') | i18n}}
                        </lv-form-control>
                    </lv-form-item>
                    <lv-form-item>
                        <lv-form-label>{{'explore_ransomware_detection_snapshot_label' | i18n}}</lv-form-label>
                        <lv-form-control>
                            <lv-group lvDirection='vertical'>
                                <span>{{triggerMap[backupItem.schedule?.trigger_action] ||
                                    triggerMap[backupItem.schedule?.interval_unit]}}</span>
                                <span>{{getDetectionPolicy(backupItem) | nil}}</span>
                                <span lv-overflow>
                                    {{'explore_time_allow_anti_snapshot_label' |
                                    i18n:[backupItem.schedule?.window_start,backupItem.schedule?.window_end]}}
                                </span>
                            </lv-group>
                        </lv-form-control>
                    </lv-form-item>
                </ng-container>
                <h3 class="aui-gutter-column-md mgt-24">{{'common_advanced_label' | i18n}}</h3>
                <lv-form-item>
                    <lv-form-label>{{'protection_job_failed_alarm_label' | i18n}}</lv-form-label>
                    <lv-form-control>
                        {{policy?.policy_list[0]?.ext_parameters?.alarm_after_failure | textMap: 'Switch_Status'}}
                    </lv-form-control>
                </lv-form-item>
                <lv-form-item>
                    <lv-form-label>{{'protection_auto_retry_label' | i18n}}</lv-form-label>
                    <lv-form-control>
                        <ng-container *ngIf="!policy?.policy_list[0]?.ext_parameters?.auto_retry">
                            {{policy?.policy_list[0]?.ext_parameters?.auto_retry | textMap: 'Switch_Status'}}
                        </ng-container>
                        <ng-container *ngIf="policy?.policy_list[0]?.ext_parameters?.auto_retry">
                            <ng-container *ngIf="i18n.isEn">
                                {{'common_retry_times_label' | i18n: []:
                                true}}{{policy?.policy_list[0]?.ext_parameters?.auto_retry_times}}
                                {{'common_times_label' |
                                i18n}}{{'common_comma_label'|i18n}}
                                {{'common_waiting_time_label' | i18n: []:
                                true}}{{policy?.policy_list[0]?.ext_parameters?.auto_retry_wait_minutes}}
                                {{'common_minutes_label' | i18n}}
                            </ng-container>
                            <ng-container *ngIf="!i18n.isEn">
                                {{'common_retry_times_label' | i18n: []:
                                true}}{{policy?.policy_list[0]?.ext_parameters?.auto_retry_times}}{{'common_times_label'
                                |
                                i18n}}{{'common_comma_label'|i18n}}
                                {{'common_waiting_time_label' | i18n: []:
                                true}}{{policy?.policy_list[0]?.ext_parameters?.auto_retry_wait_minutes}}{{'common_minutes_label'
                                | i18n}}
                            </ng-container>
                        </ng-container>
                    </lv-form-control>
                </lv-form-item>
            </lv-form>
        </ng-template>
    </lv-tab>
    <lv-tab [lvTitle]="'common_associated_resource_label' | i18n" [lvId]="'1'">
        <ng-template lv-tab-lazy>
            <aui-anti-associate-resource [policy]="policy"></aui-anti-associate-resource>
        </ng-template>
    </lv-tab>
</lv-tabs>

<ng-template #headerTpl>
    <div class="aui-operation aui-custom-modal-container">
        <div class="aui-custom-modal-title">
            <span lv-overflow class="name-warp">{{policy.name}}</span>
        </div>
        <div class="aui-custom-modal-operate" *ngIf="!!this.optItems">
            <lv-operation-menu [lvItemsFn]="optCallback" [lvData]="policy"
                lvMenuText="{{'common_operation_label'|i18n}}">
            </lv-operation-menu>
        </div>
    </div>
</ng-template>
